import 'package:flutter/material.dart';
import 'package:flutter_app2/utils/keep_alive_wrapper.dart';
import 'package:flutter_app2/view/PageView1.dart';

class PageView2 extends StatefulWidget {
  PageView2({Key? key}) : super(key: key);

  @override
  State<PageView2> createState() => _PageView2State();
}

class _PageView2State extends State<PageView2>
    with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    super.build(context);
    var children = <Widget>[];
    for (var i = 0; i < 5; i++) {
      children.add(KeepAliveWrapper(
        child: PageScroller(
          text: '$i',
        ),
      ));
    }
    return Scaffold(
      appBar: AppBar(
        title: Text("PageView_demo"),
      ),
      body: PageView(
        // allowImplicitScrolling: true,
        children: children,
      ),
    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}
